// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
	"flag"
	"github.com/gogf/gf/v2/frame/g"
	"log"
	"net/http"
	"ws/server/config"
	"ws/server/rabbitmq"
	"ws/server/utils"
	echo2 "ws/server/websocket/echo"
)

var addr = flag.String("addr", ":9000", "http service address")

func main() {
	g.Log().Info(config.Ctx, "itp websocket server start")
	//连接mq,获取相关消息
	go rabbitmq.Start()
	//websocket启动
	flag.Parse()
	http.HandleFunc("/", utils.ServeHome)
	http.HandleFunc("/c", echo2.EchoCopyWriterOnly)
	http.HandleFunc("/f", echo2.EchoCopyFull)
	http.HandleFunc("/r", echo2.EchoReadAllWriter)
	http.HandleFunc("/m", echo2.EchoReadAllWriteMessage)
	http.HandleFunc("/p", echo2.EchoReadAllWritePreparedMessage)
	err := http.ListenAndServe(*addr, nil)
	if err != nil {
		log.Fatal("ListenAndServe: ", err)
	}
}
